package LCR;

import java.util.Scanner;

// 注意类名必须为 LCR.Main, 不要有任何 package xxx 信息
class TreeNode2 {
    char val;
    TreeNode2 left;
    TreeNode2 right;
    public TreeNode2() {}
    public TreeNode2(char val) {
        this.val = val;
    }


}
public class Main {
    public static int i = 0;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String inp = in.nextLine();
            //LCR.TreeNode root = new LCR.TreeNode(inp.charAt(0));
            int len = inp.length();
            TreeNode2 root = creat(inp,len);
            mid(root);
        }
    }

    public static TreeNode2 creat(String inp,int len) {
        TreeNode2 root = null;
        if(i < len && inp.charAt(i) != '#'){
            root = new TreeNode2(inp.charAt(i));
            i++;
            root.left = creat(inp,len);
            root.right = creat(inp,len);
        }else {
            i++;
        }

        return root;

    }

    public static void mid(TreeNode2 root) {
        if (root == null) {
            return;
        }
        mid(root.left);
        System.out.print(root.val + " ");
        mid(root.right);
        return;
    }

}








